package com.cuckoo.mall.thus.menuaccount.favorite;

import com.bgn.baseframe.base.BasePresenterImpl;
import com.bgn.baseframe.network.HttpObserver;
import com.bgn.baseframe.network.bean.TDataBean;
import com.cuckoo.mall.javabean.Goods;
import com.cuckoo.mall.javabean.Product;
import com.cuckoo.mall.network.ApiManager;

import java.util.List;


/**
 * 作者：wl on 2018/4/ * 邮箱：wanglun@stosz.com
 */

public class FavoritePresenter extends BasePresenterImpl<FavoriteContract.View> implements FavoriteContract.Presenter {

    @Override
    public void loadAllFavorites(final int type) {
        ApiManager.getFavoriteList().subscribe(new HttpObserver<TDataBean<List<Product>>>(mView) {
            @Override
            public void onSucceed(TDataBean<List<Product>> value) {
                mView.whenGetFavorites(value.getData(),type);
            }
        });
    }


    @Override
    public void deleteFavorite(String product_id, final List<Integer> positions) {
        ApiManager.cancleFavorite(product_id).subscribe(new HttpObserver<TDataBean>(mView) {
            @Override
            public void onSucceed(TDataBean value) {
                mView.whenDeleteSucceed(positions);
            }
        });
    }
}
